package io.jee.medusa.orm;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;

public class PrefixPhysicalNamingStrategy extends SpringPhysicalNamingStrategy {
	
	private String tablePrefix;
	
	public PrefixPhysicalNamingStrategy(String tablePrefix) {
		this.tablePrefix = tablePrefix;
	}

	@Override
	public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
		String text = tablePrefix + name.getText();
		return super.toPhysicalTableName(Identifier.toIdentifier(text), jdbcEnvironment);
	}

}
